home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / User's Guide / 11 MacDOS Extensions < prev    next >
Text File  |  1994-09-20  |  5KB  |  107 lines

  1. 11  MacDOS Extensions
  2.        You  can extend the functionality of MacDOS by creating your
  3.        own  "pipable" filter applications. Such applications accept
  4.        as  input  the  output  of MacDOS commands  and  send  their
  5.        results back to MacDOS for display in the console window.
  6.  
  7.        To work as a filter, an application must:
  8.        •  Be of type 'APPL' and creator 'mFLR'.
  9.        •  Be able to run in the background.
  10.        •  Support  the  MacDOS communication protocol  to  exchange
  11.           messages with other processes.
  12.  
  13.        This  section only describes how to use filters that already
  14.        exist.  If  you  are  interested in creating  your  own  new
  15.        filters, please refer to Appendix B.
  16.  
  17.        Basically,  there are two ways in which you can use  filters
  18.        within the command line:
  19.  
  20.        filter1 < inFile
  21.  
  22.        or
  23.  
  24.        command | filter1
  25.  
  26.        In  the  first case, a text file is fed into filter1,  while
  27.        in  the second case, the output of a MacDOS command is  sent
  28.        to  filter1. In both examples, the output of filter1 is sent
  29.        to the console window.
  30.  
  31.        Commands  and filters have in general one or more  switches.
  32.        Also  note that the position of file redirection within  the
  33.        command    line    is    irrelevant:   output    redirection
  34.        automatically  applies  to the last (ie.  rightmost)  filter
  35.        and input redirection to the first one.
  36.  
  37.        Some examples of valid chains of commands and filters are:
  38.  
  39.        filter1 <inFile >outFile | filter2
  40.            Data   flow:  inFile   ->   filter1   ->   filter2    ->
  41.            outFile
  42.  
  43.        filter1 | filter2 <inFile
  44.            Data   flow:  inFile   ->   filter1   ->   filter2    ->
  45.            console
  46.  
  47.        dir /b/a-d | myFilter mode1 >outFile
  48.            Data flow: MacDOS  ->  myFilter  ->  outFile.
  49.            DIR  sends its output to myFilter and myFilter  executes
  50.            with the "mode1" option.
  51.  
  52.        \filterDir\filter1 <inFile | more
  53.            Data flow: inFile  ->  filter1  ->  console
  54.            MacDOS  pages  the  output of  filter1  to  the  console
  55.            window
  56.  
  57.        help filter1 | aSubDir\filter2 | filter3
  58.            Data flow: MacDOS  ->  filter2  ->  filter3  -> console
  59.            MacDOS  sends  to filter2 the help information  provided
  60.            by  filter1.  The  output  of filter2  is  processed  by
  61.            filter3 before being sent to the console window.
  62.  
  63.        A chain must satisfy the following conditions:
  64.        •  A  filter can appear anywhere (at the beginning,  between
  65.           other  filters separated by pipes, and at the  end),  but
  66.           if  it  appears at the beginning, the command  line  must
  67.           include  input  redirection (note: filter  <  inFile   is
  68.           completely equivalent to  type inFile | filter).
  69.        •  MORE can only appear in the last position of a chain.
  70.        •  MacDOS  commands (with the exception of  MORE)  can  only
  71.           appear at the beginning of a chain.
  72.  
  73.        Note  that  MacDOS  searches the table of internal  commands
  74.        before  looking for filters. Therefore, filters  named  like
  75.        commands  can  only be executed if they are  preceded  by  a
  76.        path.
  77.  
  78.        You  should  normally be able to get help on MacDOS  filters
  79.        by   typing   "help  filterName"  ("filterName/?"   is   not
  80.        supported).
  81.  
  82.    Filters and the Finder
  83.        If  you  launch a filter application by double  clicking  on
  84.        it,  you  can  ONLY terminate it by making it the  frontmost
  85.        application  and typing CNTL-C (or CMD-dot). Note  that  the
  86.        shutdown  will not work, because filters do not  accept  the
  87.        standard  AEs. This was done to reduce filter  code  to  the
  88.        minimum.
  89.  
  90.    Speed of filters
  91.        You  will find that filters are quite slow, especially  with
  92.        less  powerful  Macs.  That is, as soon  as  you  pipe  data
  93.        through  a  filter, the console window scrolls significantly
  94.        slower. This is mainly due to the process switches that  the
  95.        Mac  OS has to perform before a message goes through all the
  96.        pipes  and  back  to MacDOS. As a result of this,  you  will
  97.        probably  decide  to use MacDOS pipes only to  filter  files
  98.        and  commands  with  a  low number of lines  or  to  perform
  99.        operations in the background while you do something else.
  100.  
  101.        After  sending  a message to the first filter  of  a  chain,
  102.        MacDOS  expects to receive a message from the  last  filter.
  103.        By  default, MacDOS reports a timeout error if it  fails  to
  104.        receive  the  message after 2 seconds. You can  change  this
  105.        timeout  by  setting  the  global variable  TIMEOUT  to  the
  106.        appropriate number of seconds.
  107.